package Chat.System;

import javax.swing.JPanel;

/**
 * Onglets pour afficher les messages des personnes
 *
 * @author Ndanja & Papa Abdou
 */
public class Onglets extends JPanel {

    private String name;

    /** 
     * Creation nouvelle onglet
     */
    public Onglets(String name) {

        if (!name.equalsIgnoreCase("Fichiers")) {
            initComponents();
        }

        this.name = name;
    }

    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jScrollPane1 = new javax.swing.JScrollPane();
        chatMessage = new javax.swing.JTextArea();

        addMouseListener(new java.awt.event.MouseAdapter() {
            public void mousePressed(java.awt.event.MouseEvent evt) {
                formMousePressed(evt);
            }
        });

        chatMessage.setColumns(20);
        chatMessage.setEditable(false);
        chatMessage.setRows(5);
        chatMessage.setFocusable(false);
        jScrollPane1.setViewportView(chatMessage);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 429, Short.MAX_VALUE)
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 345, Short.MAX_VALUE)
                .addContainerGap())
        );
    }// </editor-fold>//GEN-END:initComponents

    private void formMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_formMousePressed
        // TODO add your handling code here:
        this.hide();
    }//GEN-LAST:event_formMousePressed
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JTextArea chatMessage;
    private javax.swing.JScrollPane jScrollPane1;
    // End of variables declaration//GEN-END:variables

    /**
     * Retourne le nom de l'Onglet
     * @return String
     */
    @Override
    public String getName() {
        return this.name;
    }

    /**
     *Permet d'insérer un nouveau message
     * @param texte : Teste à insérer dans le TextArea
     */
    public void setChatMessage(String texte) {
        this.chatMessage.append(texte);
    }
}
